<script>
// #ifdef H5
(function () {
  if (
    typeof WeixinJSBridge == "object" &&
    typeof WeixinJSBridge.invoke == "function"
  ) {
    handleFontSize();
  } else {
    if (document.addEventListener) {
      document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
    } else if (document.attachEvent) {
      document.attachEvent("WeixinJSBridgeReady", handleFontSize);
      document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
    }
  }

  function handleFontSize() {
    // 设置网页字体为默认大小
    WeixinJSBridge.invoke("setFontSizeCallback", {
      fontSize: 0,
    });
    // 重写设置网页字体大小的事件
    WeixinJSBridge.on("menu:setfont", function () {
      WeixinJSBridge.invoke("setFontSizeCallback", {
        fontSize: 0,
      });
    });
  }
})();
// #endif
// 引入常用方法类
import tools from "./common/sju.tools.js";
export default {
  onLaunch: function () {
    /*#ifdef APP-PLUS*/
    // plus.screen.lockOrientation('landscape-secondary');
    // plus.screen.lockOrientation('landscape-primary');
    /*#endif*/
    console.log("App Launch");
  }, onShareAppMessage() {
    uni.showToast({
      title: '分享函数被触发',
      icon: 'none'
    });
    return {
      title: this.item.title,
      path: "/pages/wenquan/wenquan?id" + this.item.id,
      imageUrl: this.shareContent.imageUrl,
      success: (res) => {
        uni.showToast({
          title: '分享成功',
          icon: 'success'
        });
      },
      fail: (err) => {
        uni.showToast({
          title: '分享失败',
          icon: 'none'
        });
      }
    }
  },
  onLoad() {
    // 确保显示分享菜单
    uni.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    });
  },
  onShow: function () {// #ifdef APP-PLUS
    uni.share({
      provider: 'weixin',
      scene: 'WXSceneSession',
      type: 0,
      title: '用户满意度调查问卷',
      summary: '邀请您参与产品体验调研...',
      imageUrl: 'https://example.com/survey.jpg',
      href: 'https://example.com/survey?id=12345',
      success: function (res) {
        console.log("分享成功：" + JSON.stringify(res));
      },
      fail: function (err) {
        console.log("分享失败：" + JSON.stringify(err));
      }
    });
    // #endif
    console.log("App Show");
    // #ifdef MP
    tools.VersionUpdate(); //小程序模式下检测小程序更新
    // #endif
  },
  onHide: function () {
    console.log("App Hide");
  },
  methods: {},
};
</script>

<style lang="scss">
@import "@/uni_modules/s-ui/styles/index.scss";

/*每个页面公共css */
page {
  background-color: $bg-color;
  font-size: $font-size-base;
  color: $text-color;
  overflow-x: hidden;
  --v-danger: #ff6b6b;
  --v-theme: #0323b2;
  --v-second: #7de6bd;
  --v-third: #151736;
  --v-green: #47c5c4;
  --v-linear: linear-gradient(to right, #0323b2, #0323b2);
  --v-bg: #f4f4f4;
  --v-white: #fff;
  --v-text: #333437;
  --v-gray: #6b7785;
  --v-text-light: #9ca1a7;
  --v-shadow: rgba(14, 63, 126, 0.01) 0px 0px 0px 1px, rgba(42, 51, 69, 0.02) 0px 1px 1px -0.5px, rgba(42, 51, 70, 0.02) 0px 3px 3px -1.5px, rgba(42, 51, 70, 0.01) 0px 6px 6px -3px, rgba(14, 63, 126, 0.01) 0px 12px 12px -6px, rgba(14, 63, 126, 0.02) 0px 24px 24px -12px;
  --v-shadow-heavy: rgba(0, 0, 0, 0.1) -4px 9px 25px -6px;
  font-size: 28rpx;
  height: 100%;
  overflow: hidden;
}

/* #ifdef H5 */
body {
  /* IOS禁止微信调整字体大小 */
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  -moz-text-size-adjust: 100% !important;
}

.uni-scroll-view-refresher {
  background: transparent !important;
}

.uni-mask {
  background: rgba(80, 75, 126, .7);
}

/* #endif */
</style>
